Skip to content

Add Group Sequential Design and Bayes Factor (Sequential) Design#87

Open
FBartos wants to merge 24 commits into
masterfrom
pr86-reapply
Open

Add Group Sequential Design and Bayes Factor (Sequential) Design#87
FBartos wants to merge 24 commits into
masterfrom
pr86-reapply

Conversation

@FBartos

@FBartos FBartos commented May 25, 2026

Copy link
Copy Markdown
Contributor

adds the following analyses:

  • Group Sequential Design (via the gsDesign R package)
  • Bayes Factor Design (via the bfpwr R package)
  • Bayes Factor Sequential Design (via the bfpwr R package)

FBartos and others added 18 commits March 5, 2026 16:26
Introduce a new Evidence analysis: export Evidence in NAMESPACE; add a stub R handler R/Evidence.R that creates an interface panel with a placeholder message (calculations to be implemented later); register the analysis in inst/Description.qml; and add the full UI definition inst/qml/Evidence.qml (QML form with parameters, priors, design options, plots, and advanced settings).
Replace placeholder Evidence interface with a full implementation: R/Evidence.R now prepares settings, computes evidence probabilities and sample-size searches, builds results/prior/design tables, explanatory HTML, and multiple plots (by N, effect size, and priors). Uses bfpwr for core Bayesian calculations and includes robust error handling and plotting via ggplot2/jaspGraphs. DESCRIPTION updated to import and reference the SamCH93/bfpwr package. UI/QML updated to add a Bayesian group and include a new powerBayes SVG icon (inst/icons/powerBayes.svg) for the Evidence analysis.
@github-actions

Copy link
Copy Markdown
Contributor

👋 Friendly reminder: It looks like NEWS.md wasn't updated in this Pull Request.

If your changes include bug fixes, new features, or UI tweaks, please consider adding a quick note to the # jaspYourModule (development version) section so our users know about your awesome work! (If this is just a minor typo fix, feel free to ignore this message.)

@FBartos

FBartos commented May 25, 2026

Copy link
Copy Markdown
Contributor Author

build builder bot, build for glory!

@github-actions

Copy link
Copy Markdown
Contributor

✅ Build Complete!

Your JASP module bundles have been successfully built for macOS (ARM) and Windows.

👉 Click here to download the artifacts

(Scroll to the bottom of the page to find the "Artifacts" section).

Comment thread .github/workflows/test-coverage.yml Fixed
…ntain permissions'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@FBartos FBartos requested review from juliuspfadt and removed request for juliuspfadt May 25, 2026 16:43
@FBartos FBartos requested a review from vandenman June 1, 2026 14:56
Form
{
info: qsTr("Bayes Factor sequential design allows you to design sequential experiments for conclusive evidence.\n\n" +
"See [this tutorial](TODO) for a detailed introduction to the module.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO is intended still?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets comment this line out for now, and put it back in once the tutorial is preprinted

Form
{
info: qsTr("Bayes Factor design allows you to design fixed sample size experiments for conclusive evidence.\n\n" +
"See [this tutorial](TODO) for a detailed introduction to the module.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO is intended still?

Comment thread R/BayesFactorDesign.R
Comment on lines +531 to +538
if (settings[["isIndependentSamples"]] && settings[["sampleSizeRatio"]] != 1)
stop(gettext("Sample-size search for unequal group sizes is handled internally."))

if (settings[["drangeMode"]] == "custom")
stop(gettext("Sample-size search for custom t search ranges is handled internally."))

if (!isTRUE(all.equal(settings[["nullValue"]], 0)))
stop(gettext("Sample-size search for nonzero null values is handled internally."))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these errors meant for users? When/ how can they occur? If they occur only when an analyst has done something wrong, they shouldn't be translated so no gettext. Please add a comment describing what these errors are for.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these errors looks odd and should be never reached

Comment thread R/BayesFactorDesign.R
.bfdReportTestLabel <- function(settings) {
.bfdRequireKnownOption(gettext("test"), settings[["test"]], .bfdKnownTests)

switch(settings[["test"]],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same switch statement as .bfdTestLabel, avoid duplication.

Comment thread R/BayesFactorDesign.R
Comment on lines +3809 to +3829
.bfdPriorSpikeRow <- function(x, prior, height) {
return(data.frame(
x = x,
height = height,
prior = prior,
stringsAsFactors = FALSE
))
}

.bfdPriorSpikeRows <- function(rows) {
if (length(rows) == 0) {
return(data.frame(
x = numeric(0),
height = numeric(0),
prior = character(0),
stringsAsFactors = FALSE
))
}

return(do.call(rbind, rows))
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.bfdPriorSpikeRow <- function(x, prior, height) {
return(data.frame(
x = x,
height = height,
prior = prior,
stringsAsFactors = FALSE
))
}
.bfdPriorSpikeRows <- function(rows) {
if (length(rows) == 0) {
return(data.frame(
x = numeric(0),
height = numeric(0),
prior = character(0),
stringsAsFactors = FALSE
))
}
return(do.call(rbind, rows))
}
.bfdPriorSpikeRow <- function(x, prior, height) {
return(data.frame(
x = x,
height = height,
prior = prior,
stringsAsFactors = FALSE
))
}
.bfdPriorSpikeRows <- function(rows) {
if (length(rows) == 0) {
return(.bfdPriorSpikeRow(numeric(), numeric(), character()))
}
return(do.call(rbind, rows))
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too much duplication again

isZTest = grepl("ZTest", test, fixed = TRUE) || identical(test, "generalZApproximation"),
isBinomial = FALSE,
calculation = options[["calculationTarget"]],
bf10Threshold = options[["conclusiveEvidenceThresholdH1"]],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is confusion and renames some options. Why not just add options as a whole to the settings? That way someone can understand which name maps onto which option in QML.

Comment on lines +1 to +11
.bfdCreatePlot <- function(parent, key, title, position, dependencies, width, height) {
if (!is.null(parent[[key]]))
return(NULL)

plot <- createJaspPlot(title = title, width = width, height = height)
plot$dependOn(dependencies)
plot$position <- position
parent[[key]] <- plot

return(plot)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels overengineered.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100% agree

Comment on lines +13 to +32
.bfdCachedPlotData <- function(jaspResults, stateKey, dependencies, dataKey, compute) {
state <- jaspResults[[stateKey]]
if (is.null(state)) {
state <- createJaspState()
state$dependOn(dependencies)
jaspResults[[stateKey]] <- state
}

cache <- state$object
if (is.null(cache))
cache <- list()

if (!is.null(cache[[dataKey]]))
return(cache[[dataKey]])

cache[[dataKey]] <- try(compute(), silent = TRUE)
state$object <- cache

return(cache[[dataKey]])
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +115 to +121
html <- .bfdCreateHtml(
parent = parent,
key = key,
title = title,
position = position,
dependencies = dependencies
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bfdCreateHtml is likely also overengineered

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fully agree

Comment thread R/GroupSequentialDesign.R
testType = testType,
designTypeLabel = .csdDesignTypeLabel(options[["designType"]]),
numberOfLooks = options[["numberOfLooks"]],
timingMode = options[["timingMode"]],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same remark as before, just append options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants